﻿namespace wwl.Contract.Interfaces.Security
{
  /// <summary>
  /// 密码哈希器接口（契约层定义）
  /// 定义密码哈希和验证的核心契约，支持多种哈希算法
  /// </summary>
  public interface IHasher
  {
    /// <summary>
    /// 对明文密码进行哈希处理
    /// </summary>
    /// <param name="password">明文密码</param>
    /// <returns>哈希后的密码字符串</returns>
    string HashPassword(string password);

    /// <summary>
    /// 验证密码是否与哈希值匹配
    /// </summary>
    /// <param name="password">待验证的明文密码</param>
    /// <param name="hashedPassword">已哈希的密码</param>
    /// <returns>验证成功返回true，否则返回false</returns>
    bool VerifyPassword(string password, string hashedPassword);

    /// <summary>
    /// 检查密码强度
    /// </summary>
    /// <param name="password">待检查的密码</param>
    /// <returns>密码强度等级</returns>
    PasswordStrength CheckPasswordStrength(string password);
  }

  /// <summary>
  /// 密码强度等级
  /// </summary>
  public enum PasswordStrength
  {
    /// <summary>密码为空或过短</summary>
    TooWeak,
    /// <summary>强度弱</summary>
    Weak,
    /// <summary>强度中等</summary>
    Medium,
    /// <summary>强度强</summary>
    Strong,
    /// <summary>强度非常强</summary>
    VeryStrong
  }
}